<template>
	<view class="box">
		<view class="iptwrap">
			<text>联系电话:</text>
			<input type="number" :value="name" @input="getname" />
		</view>
		<view class="tip">
			可以让你的社区成员/直推商家通过电话与你联系
		</view>
		<view class="btn" @click="edits" >
			保存
		</view>
	</view>
</template>

<script>
	import {myuser,edituser}from "../../api/user.js"
	export default {
		data() {
			return {
				name:"",
				user:{}
			}
		},
		onLoad() {
			this.getuser()
		},
		onReady() {
		},
		methods: {
			edits(){
				if (!uni.$u.test.mobile(this.name)) {
					uni.$u.toast("请输入正确的手机号")
					return
				} 
				edituser({
					contact_number:this.name
				}).then(res=>{
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
					}
					uni.$u.toast(res.msg)
				})
			},
				
			getuser(){
				myuser().then(res=>{
					this.name=res.data.contact_number
				})
			},
			getname(e){
				this.name=e.detail.value
				console.log(e)
			}
		},
	}
</script>

<style lang="scss">
	.iptwrap{
		width: 750rpx;
		height: 88rpx;
		background: #FFFFFF;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin-top: 40rpx;
		display: flex;
		align-items: center;
		>text{
			margin-left: 40rpx;
			font-weight: 400;
			font-size: 30rpx;
			color: #666666;
		}
		>input{
			width: 500rpx;
			padding-left: 20rpx;
			font-weight: 400;
			font-size: 30rpx;
			color: #333333;
		}
	}
	.tip{
		width: 690rpx;
		margin: 0 auto;
		font-weight: 400;
		font-size: 26rpx;
		color: #999999;
		margin-top: 24rpx;
	}
	.btn{
		width: 690rpx;
		height: 80rpx;
		background: linear-gradient( 90deg, #FA2222 2%, #FFC400 98%);
		border-radius: 190rpx 190rpx 190rpx 190rpx;
		text-align: center;
		line-height: 80rpx;
		font-weight: 400;
		font-size: 36rpx;
		color: #FFFFFF;
		margin: 0 auto;
		margin-top: 56rpx;
	}
</style>